<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1,user-scalable=no">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<link rel="Shortcut Icon" href="./images/logo.png">
<link rel="stylesheet" href="./css/mui.min.css">
<title>APP下载</title>
<style>
html, body {
	height: 100%
}

.mui-content-padded {
	margin: 5px;
}

.mui-content {
	width: 300px;
	height: 250px;
	position: absolute;
	left: 50%;
	top: 50%;
	margin: -250px 0 0 -150px;
	background-color: initial;
}

.mui-table-view {
	background-color: initial;
}

.bg {
	background-image: url(./images/home.jpg);
	background-size: 100% 100%;
	background-repeat: no-repeat;
}

.logo {
	height: 150px;
	text-align: center;
}

img {
	max-width: 100%;
	height: auto;
}
</style>
</head>

<body class="bg">
	<div class="mui-content">
		<div class="mui-content-padded">
			<div class="logo">
				<img id="logoimg" src="./images/logo.png" width="120px" height="120px" style="visibility: hidden;"/>
			</div>
			<div class="form-row">
				<input type="number" placeholder="手机号" id="mobile">
			</div>
			<div class="form-row mui-text-center">
				<button type="button" class="mui-btn mui-btn-warning" style="width: 100%;">免费下载</button>
			</div>
		</div>
	</div>
</body>
<script type="text/javascript" src="./js/mui.min.js"></script>
<script type="text/javascript" src="./js/validator.min.js"></script>
<script type="text/javascript" src="./js/public.js"></script>
<script type="text/javascript" src="./js/jquery-1.8.3.min.js"></script>
<script>
	mui.init();
	$(function() {
		if (mui.os.wechat) {
			var winHeight = typeof window.innerHeight != 'undefined' ? window.innerHeight
					: document.documentElement.clientHeight;
			var weixinTip = $('<div id="weixinTip"><p><img src="./images/live_weixin.png" alt="微信打开"/></p></div>');
			$("body").append(weixinTip);

			$("#weixinTip").css({
				"position" : "fixed",
				"left" : "0",
				"top" : "0",
				"height" : winHeight,
				"width" : "100%",
				"z-index" : "1000",
				"background-color" : "rgba(0,0,0,0.8)",
				"filter" : "alpha(opacity=80)",
			});
			$("#weixinTip p").css({
				"text-align" : "center",
				"margin-top" : "10%",
				"padding-left" : "5%",
				"padding-right" : "5%"
			});
			return;
		}

		var url_android = "https://qiangfantian.oss-cn-zhangjiakou.aliyuncs.com/qft.apk";
		var url_ios = "itms-services://?action=download-manifest&url=https://qiangfantian.oss-cn-zhangjiakou.aliyuncs.com/qft.plist"
		$("button.mui-btn-warning").click(function() {
			if (!validator.isMobilePhone($("#mobile").val(), 'zh-CN')) {
				mymui("请输入正确的手机号");
				return;
			}
			mui.postParam("api/downloadapp", {
				mobile : $("#mobile").val(),
				recPerson : getUrlParam("code")
			}, function(result) {
				if (result.code == 0) {
					window.location.href = mui.os.ios ? url_ios : url_android;
					return;
				}
				mymui(result.msg);
			});
		});
	});

	function getUrlParam(name) {
		var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); //构造一个含有目标参数的正则表达式对象
		var r = window.location.search.substr(1).match(reg); //匹配目标参数
		if (r != null)
			return unescape(r[2]);
		return null; //返回参数值
	}
</script>

</html>